import sys
importFile = open(sys.argv[1], 'r')
key = sys.argv[2]
numbers = []
for char in key:
  numbers.append(int(char))


splitFiles = []
for num in numbers :
  f = open(sys.argv[1] + ".split-" + str(num), "w", encoding="utf-8")
  splitFiles.append(f);



count = len(splitFiles)


for lineStr  in importFile :
  offset = 0
  lineStr = lineStr[:-1]
  while offset < len(lineStr):
    for idx in range(count):
      if (offset + numbers[idx] > len(lineStr)):
        chars = lineStr[offset: len(lineStr)]
      else :
        chars = lineStr[offset : offset + numbers[idx]]

      offset = offset + numbers[idx]
      splitFiles[idx].write(chars)
      if (offset >= len(lineStr)):
        break
  for idx in range(count):
    splitFiles[idx].write("\n")




importFile.close()

